<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>watch属性</title>
    <!-- 引用vue.js库 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
      <button @click="a++">加1的操作</button>
      <input type="text" v-model="a">
      <p>{{message}}</p>
    </div>
    <script>
        let vm = new Vue({
            // 根据id获取到容器div
            el:"#app",
            // data表示数据
            data:{
              message:"",  
              a:1
            },
            methods:{
               
            },
            computed: {
              
            },
            // 监听器
            watch:{
                a:function(val,oldval) {
                    this.message = "a的旧值:"+oldval+"新的值:"+val
                }
            }
        });
    </script>
    
</body>
</html>